/*
 * stateMachine.h
 *
 *  Created on: 19/nov/2009
 *      Author: Antonio Marullo
 */

#ifndef STATEMACHINE_H_
#define STATEMACHINE_H_
#include "stdint.h"
//supporto esito valutazione stato
typedef uint16_t StateOutcome;
#define EVENT_IGNORED 0
#define EVENT_HANDLED 1
#define EVENT_CHANGED 2
//supporto eventi
typedef struct{
	uint16_t signature;
	void* data;
} Event;
extern const Event initEvent;
extern const Event exitEvent;
extern const Event entryEvent;
#define INIT_CODE 0x0000
#define EXIT_CODE 0x0001
#define ENTRY_CODE 0x0002
//supporto prototipi puntatori a funzione
typedef StateOutcome (*StateHandler) (void* me,const Event* e);
typedef void (*TransitionAction) (void* me);
typedef void (*Notifier) (void*);
//classe astratta macchina a stati
typedef struct{
	StateHandler state;
	TransitionAction passageAction;
} StateMachine;
void stateMachineOnInit(void* me, StateHandler initState);
void stateMachineOnInit2(void* me,StateHandler initState,Event* e);
void stateMachineDispatcher(void* me, const Event* e);
#endif /* STATEMACHINE_H_ */
